layui.use(['table', 'jquery'], function () {
    var table = layui.table,
        $ = layui.jquery;

    let id = sessionStorage.getItem("teamMemberId");

    findStudentByTeam();

    function findStudentByTeam() {
        //table样式
        table.render({
            elem: '#dataList'
            , url: URL + "/team/findStudentByTeam"
            , where: {id: id}
            , method: 'get' //如果无需自定义HTTP类型，可不加该参数
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , height: 300
            , skin: 'line' //表格风格
            , even: true  //双数
            , page: false //是否显示分页
            , title: '小组成员表'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'id', width: 80, title: 'ID', sort: true, fixed: 'left'}
                , {field: 'studentId', width: 80, title: '学号', sort: true}
                , {field: 'username', width: 80, title: '用户名'}
               /* , {
                    field: 'userRole', width: 130, title: '用户角色', templet: function (e) {
                        let result = e.userRole;
                        return showUserRole(result);
                    }
                }*/
                , {
                    field: 'avatar', width: 120, title: '头像', templet: function (e) {
                        //判断图片是否为空
                        e.avatar === null || e.avatar === undefined ? e.avatar = '/upload/img_null.png' : e.avatar;
                        return '<img src="' + e.avatar + '" width="80px" height="30px">'
                    }
                }
                , {
                    field: 'team', width: 160, title: '小组', templet: e => {
                        if (e.team != null && e.team !== undefined && e.team !== '') {
                            return e.team;
                        } else {
                            return '暂未分配';
                        }
                    }
                }
                , {field: 'genderStr', width: 80, title: '性别', sort: true}
                , {field: 'birthday', title: '生日', width: '20%', minWidth: 100}
                , {field: 'phone', width: 80, title: '电话'}
                , {field: 'hometown', width: 80, title: '籍贯'}
                , {field: 'degreeStr', title: '学历'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增
                , {field: 'introduce', title: '自我介绍', sort: true}
                , {field: 'sequence', title: '排序号', sort: true}
            ]]

        });
    }

});